package com.utils;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.InvocationHandler;

import java.lang.reflect.Method;

public class CgLibProxy {
    public Object createson(Object proxyObject){
      return   Enhancer.create(proxyObject.getClass(), new InvocationHandler() {
            @Override
            public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
                System.out.println("cglib代理开始");
                Object invoke = method.invoke(proxyObject, objects);
                System.out.println("cglib代理结束");
                return invoke;
            }
        });
    }
}
